package com.example.fanday.play.di.module;

import android.app.Activity;
import android.app.Fragment;
import android.content.Context;

import com.example.fanday.play.cons.Dagger2Cons;
import com.example.fanday.play.di.scope.ContextLife;
import com.example.fanday.play.di.scope.PerFragment;

import dagger.Module;
import dagger.Provides;

/**
 * Created by fanday on 2017/8/13.
 */
@Module
public class FragmentModule {
    private Fragment fragment;

    public FragmentModule(Fragment fragment) {
        this.fragment = fragment;
    }

    @Provides
    @ContextLife(Dagger2Cons.FRAGMENT)
    @PerFragment
    public Context providerFragmentContext(){
        return fragment.getActivity();
    }

    @PerFragment
    @Provides
    public Fragment providerFragment() {
        return fragment;
    }
    @Provides
    @PerFragment
    public Activity providerFragmentActivity(){
        return fragment.getActivity();
    }
}
